package com.dove.controller;

import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSON;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/redis")
public class RedisController {

    private Logger logger = LoggerFactory.getLogger(this.getClass());


    @Autowired
	private StringRedisTemplate stringRedisTemplate;

	/**
	 * redis test
	 * @param id
	 * @return
	 */
	@PostMapping("/redis.channel.test")
	public String test(String out_trade_no) {
		logger.info("redis.channel.test");
		Map<String, String> map = new HashMap<String, String>();
		map.put("out_trade_no", out_trade_no);
		// 已经将redis 全部注释 待后期 再需
		stringRedisTemplate.convertAndSend("redis.channel.test", JSON.toJSONString(map));
		return "success";
	}
}